/*************************************************************************
	> File Name: oj-223_v2.cpp
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2021年01月19日 星期二 09时50分39秒
 ************************************************************************/
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX_N 10000

struct {
    long long sum;
    int tag;
} tree[MAX_N << 2];

int arr[MAX_N + 5];

void update(int ind) {
    tree[ind].sum = tree[ind << 1].sum + tree[ind << 1 | 1].sum;
}

void build_tree(int ind, int l, int r) {
    if (l == r) {
        tree[ind].sum = arr[l];
        return ;
    }
    int mid = (l + r) >> 1;
    build_tree(ind << 1, l, mid);
    build_tree(ind << 1 | 1, mid + 1, r);
    update(ind);
    return ;
}

void down(int ind, int l, int r) { //对l,r区间懒标记下沉
    if (tree[ind].tag) { //如果节点存在懒标记
        int val = tree[ind].tag;
        int mid = (l + r) >> 1;
        //懒标记下沉到左子树
        tree[ind << 1].sum += val * (mid - l + 1);
        tree[ind << 1].tag += val;
        //懒标记下沉到右子树
        tree[ind << 1 | 1].sum += val * (r - mid);
        tree[ind << 1 | 1].tag += val;
        //当前节点懒标记置零
        tree[ind].tag = 0;
    }
}

void modify(int ind, int l, int r, int x, int y, int val) {
    if (x <= l && r <= y) { //如果当前节点的区间在待修改区间范围内
        //直接标记懒标记即可
        tree[ind].sum += val * (r - l + 1);
        tree[ind].tag += val;
        return ;
    }
    down(ind, l, r); //懒标记下沉
    int mid = (l + r) >> 1;
    if (mid >= x) {
        modify(ind << 1, l, mid, x, y, val);
    }
    if (mid < y) {
        modify(ind << 1 | 1, mid + 1, r, x, y, val);
    }
    update(ind);
}

long long query(int ind, int l, int r, int x, int y) {
    if (x <= l && r <= y) {
        return tree[ind].sum;
    }
    down(ind, l, r);
    int mid = (l + r) >> 1;
    long long ans = 0;
    if (mid >= x) {
        ans += query(ind << 1, l, mid, x, y);
    } 
    if (mid < y) {
        ans += query(ind << 1 | 1, mid + 1, r, x, y);
    }
    return ans;
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", arr + i);
    }
    build_tree(1, 1, n);
    int a, b, c, d;
    for (int i = 0; i < m; ++i) {
        scanf("%d%d%d", &a, &b, &c);
        switch (a) {
            case 1:
                scanf("%d", &d);
                modify(1, 1, n, b, c, d); //
                break;
            case 2:
                if (b > c) printf("0\n");
                else printf("%lld\n", query(1, 1, n, b, c));
                break;
        }
    }
    return 0;
}
